package com.pro.springbootshop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pro.springbootshop.entity.FlashActivity;
import com.pro.springbootshop.entity.Wares;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FlashActivityMapper extends BaseMapper<FlashActivity> {
    @Select("select * from flash_activity  where flash_activity_id=#{flashActivityId}")
    @Results(
            {
                    @Result(column = "flash_activity_id",property = "flashActivityId"),
                    @Result(column = "seller_id",property = "sellerId"),
                    @Result(column = "wares_number",property = "waresNumber"),
                    @Result(column = "start_time",property = "startTime"),
                    @Result(column = "finish_time_activity",property = "finishTimeActivity"),
                    @Result(column = "finish_time_entry",property = "finishTimeEntry"),
                    @Result(column = "flash_activity_state",property = "flashActivityState"),
                    @Result(column = "discount",property = "discount"),
                    @Result(column = "wares_id",property = "wares",javaType = Wares.class,
                            one=@One(select = "com.pro.springbootshop.mapper.WaresMapper.selectById")
                    )
            }
    )
    FlashActivity getFlashActivityById(@Param("flashActivityId") int flashActivityId);
    @Select("select * from flash_activity limit #{pageNo},#{limit}")
    @Results(
            {
                    @Result(column = "flash_activity_id",property = "flashActivityId"),
                    @Result(column = "seller_id",property = "sellerId"),
                    @Result(column = "wares_number",property = "waresNumber"),
                    @Result(column = "start_time",property = "startTime"),
                    @Result(column = "finish_time_activity",property = "finishTimeActivity"),
                    @Result(column = "finish_time_entry",property = "finishTimeEntry"),
                    @Result(column = "flash_activity_state",property = "flashActivityState"),
                    @Result(column = "discount",property = "discount"),
                    @Result(column = "wares_id",property = "wares",javaType = Wares.class,
                            one=@One(select = "com.pro.springbootshop.mapper.WaresMapper.selectById")
                    )
            }
    )
    List<FlashActivity> getAllFlashActivity(@Param("pageNo") int pageNo, @Param("limit") int limit);
    @Select("select * from flash_activity where seller_id=#{sellerId} limit #{pageNo},#{limit}")
    @Results(
            {
                    @Result(column = "flash_activity_id",property = "flashActivityId"),
                    @Result(column = "seller_id",property = "sellerId"),
                    @Result(column = "wares_number",property = "waresNumber"),
                    @Result(column = "start_time",property = "startTime"),
                    @Result(column = "finish_time_activity",property = "finishTimeActivity"),
                    @Result(column = "finish_time_entry",property = "finishTimeEntry"),
                    @Result(column = "flash_activity_state",property = "flashActivityState"),
                    @Result(column = "wares_id",property = "wares",javaType = Wares.class,
                            one=@One(select = "com.pro.springbootshop.mapper.WaresMapper.selectById")
                    )
            }
    )
    List<FlashActivity> sellerGetAllFlashActivity(@Param("pageNo") int pageNo, @Param("limit") int limit, @Param("sellerId") String sellerId);



}